package org.jmresler.fbi.nibrs.config;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;

@Configuration
public class BatchConfiguration {

    @Autowired
    @Qualifier("nibrsJdbcTemplate")
    protected JdbcTemplate nibrsJdbcTemplate;


    @Autowired
    @Qualifier("metaJdbcTemplate")
    protected JdbcTemplate todosJdbcTemplate;


    @Bean
    public Job job(
            final JobRepository repository,
            final Step step
    ) {
        return new JobBuilder("job", repository).start(step).build();
    }

    @Bean
    public Step step(
            final JobRepository repository,
            final PlatformTransactionManager transactionManager
            ) {
        return new StepBuilder("step", repository).tasklet((contribution, chunkContext) -> {
                return null;
        }, transactionManager).build();
    }
}
